<<<<<<< HEAD
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Scanner;

class RandomPicker {
    private ClassManager classManager;
    private GroupManager groupManager;
    private StudentManager studentManager;
    private Random random;
    private Map<String, Double> studentScores;
    private Map<String, Integer> groupScores;
    private Map<String, String> attendanceRecords;

    public RandomPicker(ClassManager classManager, GroupManager groupManager, StudentManager studentManager) {
        this.classManager = classManager;
        this.groupManager = groupManager;
        this.studentManager = studentManager;
        this.random = new Random();
        this.studentScores = new HashMap<>();
        this.groupScores = new HashMap<>();
        this.attendanceRecords = new HashMap<>();
    }

    public void randomPick(Scanner scanner) {
        System.out.println("随机点名");
        System.out.println("1. 随机抽取小组");
        System.out.println("2. 随机在小组中抽取学生");
        System.out.println("3. 随机在班级里抽取学生");
        System.out.println("4. 给小组评分");
        System.out.println("5. 记录学生考勤");
        System.out.println("6. 导出成绩");
        System.out.print("请选择操作: ");

        int choice = scanner.nextInt();
        scanner.nextLine(); // 清除换行符

        switch (choice) {
            case 1:
                pickRandomGroup();
                break;
            case 2:
                pickRandomStudentFromGroup(scanner);
                break;
            case 3:
                pickRandomStudentFromClass(scanner);
                break;
            case 4:
                gradeGroup(scanner);
                break;
            case 5:
                recordAttendance(scanner);
                break;
            case 6:
                exportGrades();
                break;
            default:
                System.out.println("无效选择");
        }
    }

    public void pickRandomGroup() {
        List<String> groups = groupManager.getGroups();
        if (groups.isEmpty()) {
            System.out.println("没有可用的小组");
            return;
        }
        int randomIndex = random.nextInt(groups.size());
        System.out.println("随机抽取的小组是: " + groups.get(randomIndex));
    }

    public void pickRandomStudentFromGroup(Scanner scanner) {
        List<String> groups = groupManager.getGroups();
        if (groups.isEmpty()) {
            System.out.println("没有可用的小组");
            return;
        }

        System.out.println("可用的小组:");
        for (int i = 0; i < groups.size(); i++) {
            System.out.println((i + 1) + ". " + groups.get(i));
        }
        System.out.print("请选择小组 (输入编号): ");
        int groupIndex = scanner.nextInt() - 1;
        scanner.nextLine(); // 清除换行符

        if (groupIndex < 0 || groupIndex >= groups.size()) {
            System.out.println("无效的小组编号");
            return;
        }

        List<String> students = studentManager.getStudents();
        if (students.isEmpty()) {
            System.out.println("没有可用的学生");
            return;
        }
        int randomIndex = random.nextInt(students.size());
        System.out.println("随机抽取的学生是: " + students.get(randomIndex));
    }

    public void pickRandomStudentFromClass(Scanner scanner) {
        List<String> students = studentManager.getStudents();
        if (students.isEmpty()) {
            System.out.println("没有可用的学生");
            return;
        }
        int randomIndex = random.nextInt(students.size());
        System.out.println("随机抽取的学生是: " + students.get(randomIndex));
    }

    public void gradeGroup(Scanner scanner) {
        List<String> groups = groupManager.getGroups();
        if (groups.isEmpty()) {
            System.out.println("没有可用的小组");
            return;
        }

        System.out.println("可用的小组:");
        for (int i = 0; i < groups.size(); i++) {
            System.out.println((i + 1) + ". " + groups.get(i));
        }
        System.out.print("请选择小组 (输入编号): ");
        int groupIndex = scanner.nextInt() - 1;
        scanner.nextLine(); // 清除换行符

        if (groupIndex < 0 || groupIndex >= groups.size()) {
            System.out.println("无效的小组编号");
            return;
        }

        System.out.print("请输入评分 (0-100): ");
        int score = scanner.nextInt();
        scanner.nextLine(); // 清除换行符

        String groupName = groups.get(groupIndex);
        recordGroupScore(groupName, score);
        System.out.println("已记录小组 " + groupName + " 的评分为: " + score);
    }

    public void recordAttendance(Scanner scanner) {
        List<String> students = studentManager.getStudents();
        if (students.isEmpty()) {
            System.out.println("没有可用的学生");
            return;
        }

        System.out.println("可用的学生:");
        for (int i = 0; i < students.size(); i++) {
            System.out.println((i + 1) + ". " + students.get(i));
        }
        System.out.print("请选择学生 (输入编号): ");
        int studentIndex = scanner.nextInt() - 1;
        scanner.nextLine(); // 清除换行符

        if (studentIndex < 0 || studentIndex >= students.size()) {
            System.out.println("无效的学生编号");
            return;
        }

        String studentName = students.get(studentIndex);
        System.out.print("是否到场? (是/否): ");
        String attendance = scanner.nextLine();
        attendanceRecords.put(studentName, attendance);
        System.out.println("已记录 " + studentName + " 的考勤状态为: " + attendance);
    }

    public void recordStudentScore(String studentName, double score) {
        studentScores.put(studentName, score);
    }

    public void recordGroupScore(String groupName, int score) {
        groupScores.put(groupName, score);
    }

    public Map<String, Double> getStudentScores() {
        return studentScores;
    }

    public Map<String, Integer> getGroupScores() {
        return groupScores;
    }

    public void exportGrades() {
        System.out.println("\n=== 成绩报告 ===");

        System.out.println("\n学生成绩:");
        if (studentScores.isEmpty()) {
            System.out.println("暂无学生成绩记录");
        } else {
            for (Map.Entry<String, Double> entry : studentScores.entrySet()) {
                System.out.println(entry.getKey() + ": " + entry.getValue());
            }
        }

        System.out.println("\n小组成绩:");
        if (groupScores.isEmpty()) {
            System.out.println("暂无小组成绩记录");
        } else {
            for (Map.Entry<String, Integer> entry : groupScores.entrySet()) {
                System.out.println(entry.getKey() + ": " + entry.getValue());
            }
        }

        System.out.println("\n考勤记录:");
        if (attendanceRecords.isEmpty()) {
            System.out.println("暂无考勤记录");
        } else {
            for (Map.Entry<String, String> entry : attendanceRecords.entrySet()) {
                System.out.println(entry.getKey() + ": " + entry.getValue());
            }
        }
    }
=======
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Scanner;

class RandomPicker {
    private ClassManager classManager;
    private GroupManager groupManager;
    private StudentManager studentManager;
    private Random random;
    private Map<String, Double> studentScores;
    private Map<String, Integer> groupScores;
    private Map<String, String> attendanceRecords;

    public RandomPicker(ClassManager classManager, GroupManager groupManager, StudentManager studentManager) {
        this.classManager = classManager;
        this.groupManager = groupManager;
        this.studentManager = studentManager;
        this.random = new Random();
        this.studentScores = new HashMap<>();
        this.groupScores = new HashMap<>();
        this.attendanceRecords = new HashMap<>();
    }

    public void randomPick(Scanner scanner) {
        System.out.println("随机点名");
        System.out.println("1. 随机抽取小组");
        System.out.println("2. 随机在小组中抽取学生");
        System.out.println("3. 随机在班级里抽取学生");
        System.out.println("4. 给小组评分");
        System.out.println("5. 记录学生考勤");
        System.out.println("6. 导出成绩");
        System.out.print("请选择操作: ");

        int choice = scanner.nextInt();
        scanner.nextLine(); // 清除换行符

        switch (choice) {
            case 1:
                pickRandomGroup();
                break;
            case 2:
                pickRandomStudentFromGroup(scanner);
                break;
            case 3:
                pickRandomStudentFromClass(scanner);
                break;
            case 4:
                gradeGroup(scanner);
                break;
            case 5:
                recordAttendance(scanner);
                break;
            case 6:
                exportGrades();
                break;
            default:
                System.out.println("无效选择");
        }
    }

    public void pickRandomGroup() {
        List<String> groups = groupManager.getGroups();
        if (groups.isEmpty()) {
            System.out.println("没有可用的小组");
            return;
        }
        int randomIndex = random.nextInt(groups.size());
        System.out.println("随机抽取的小组是: " + groups.get(randomIndex));
    }

    public void pickRandomStudentFromGroup(Scanner scanner) {
        List<String> groups = groupManager.getGroups();
        if (groups.isEmpty()) {
            System.out.println("没有可用的小组");
            return;
        }

        System.out.println("可用的小组:");
        for (int i = 0; i < groups.size(); i++) {
            System.out.println((i + 1) + ". " + groups.get(i));
        }
        System.out.print("请选择小组 (输入编号): ");
        int groupIndex = scanner.nextInt() - 1;
        scanner.nextLine(); // 清除换行符

        if (groupIndex < 0 || groupIndex >= groups.size()) {
            System.out.println("无效的小组编号");
            return;
        }

        List<String> students = studentManager.getStudents();
        if (students.isEmpty()) {
            System.out.println("没有可用的学生");
            return;
        }
        int randomIndex = random.nextInt(students.size());
        System.out.println("随机抽取的学生是: " + students.get(randomIndex));
    }

    public void pickRandomStudentFromClass(Scanner scanner) {
        List<String> students = studentManager.getStudents();
        if (students.isEmpty()) {
            System.out.println("没有可用的学生");
            return;
        }
        int randomIndex = random.nextInt(students.size());
        System.out.println("随机抽取的学生是: " + students.get(randomIndex));
    }

    public void gradeGroup(Scanner scanner) {
        List<String> groups = groupManager.getGroups();
        if (groups.isEmpty()) {
            System.out.println("没有可用的小组");
            return;
        }

        System.out.println("可用的小组:");
        for (int i = 0; i < groups.size(); i++) {
            System.out.println((i + 1) + ". " + groups.get(i));
        }
        System.out.print("请选择小组 (输入编号): ");
        int groupIndex = scanner.nextInt() - 1;
        scanner.nextLine(); // 清除换行符

        if (groupIndex < 0 || groupIndex >= groups.size()) {
            System.out.println("无效的小组编号");
            return;
        }

        System.out.print("请输入评分 (0-100): ");
        int score = scanner.nextInt();
        scanner.nextLine(); // 清除换行符

        String groupName = groups.get(groupIndex);
        recordGroupScore(groupName, score);
        System.out.println("已记录小组 " + groupName + " 的评分为: " + score);
    }

    public void recordAttendance(Scanner scanner) {
        List<String> students = studentManager.getStudents();
        if (students.isEmpty()) {
            System.out.println("没有可用的学生");
            return;
        }

        System.out.println("可用的学生:");
        for (int i = 0; i < students.size(); i++) {
            System.out.println((i + 1) + ". " + students.get(i));
        }
        System.out.print("请选择学生 (输入编号): ");
        int studentIndex = scanner.nextInt() - 1;
        scanner.nextLine(); // 清除换行符

        if (studentIndex < 0 || studentIndex >= students.size()) {
            System.out.println("无效的学生编号");
            return;
        }

        String studentName = students.get(studentIndex);
        System.out.print("是否到场? (是/否): ");
        String attendance = scanner.nextLine();
        attendanceRecords.put(studentName, attendance);
        System.out.println("已记录 " + studentName + " 的考勤状态为: " + attendance);
    }

    public void recordStudentScore(String studentName, double score) {
        studentScores.put(studentName, score);
    }

    public void recordGroupScore(String groupName, int score) {
        groupScores.put(groupName, score);
    }

    public Map<String, Double> getStudentScores() {
        return studentScores;
    }

    public Map<String, Integer> getGroupScores() {
        return groupScores;
    }

    public void exportGrades() {
        System.out.println("\n=== 成绩报告 ===");

        System.out.println("\n学生成绩:");
        if (studentScores.isEmpty()) {
            System.out.println("暂无学生成绩记录");
        } else {
            for (Map.Entry<String, Double> entry : studentScores.entrySet()) {
                System.out.println(entry.getKey() + ": " + entry.getValue());
            }
        }

        System.out.println("\n小组成绩:");
        if (groupScores.isEmpty()) {
            System.out.println("暂无小组成绩记录");
        } else {
            for (Map.Entry<String, Integer> entry : groupScores.entrySet()) {
                System.out.println(entry.getKey() + ": " + entry.getValue());
            }
        }

        System.out.println("\n考勤记录:");
        if (attendanceRecords.isEmpty()) {
            System.out.println("暂无考勤记录");
        } else {
            for (Map.Entry<String, String> entry : attendanceRecords.entrySet()) {
                System.out.println(entry.getKey() + ": " + entry.getValue());
            }
        }
    }
>>>>>>> origin/master
}